<html>
	<head>
		<style>
			textarea{
				resize:none;
			}
		</style>
	</head>
</html>
<?php
if(isset($_SESSION['idUsers']))
{
	
	$query ="SELECT idProducts
		FROM products
		WHERE  idOwner='{$_SESSION['idUsers']}'
		GROUP BY idProducts"; /*"SELECT idProducts,Idimages
		FROM products,images 
		WHERE  idOwner='{$_SESSION['idUsers']}' and images.idProduct=products.idProducts 
		GROUP BY idProducts";*/
	$result_ids = DBLib::execute_query($query);
		
		
	$num_ids = mysql_num_rows($result_ids);
		
	
	if($num_ids==0){ echo "<br>" ;echo "Δεν βρέθηκαν προϊόντα προς εμφάνιση";}
	
	else
	{
		while($productId[] = mysql_fetch_array($result_ids,MYSQL_ASSOC));
		//array_pop($productId);
	
	
		echo"<table width='780' cellpadding='2' border='1' rules='all'>";
		
			echo"<th width=350 align='left'>Title</th>";
			echo"<th width=380 align='left'>Price</th>";
			echo "<th width=300 align='left'>Descrption</th>";
			echo"<th width=380 align='left'>Quantity</th>";                  
			echo"<th width=200 align='left'>Image</th>";
			$i=0;
			$j=0;//
			foreach($productId as $id)
			{
				if($id){
					$products = read_product($id['idProducts']);
				
					$imid=get_imageid_of_product2($id['idProducts']);
					array_pop($imid);
					//var_dump($imid);
					//$j=$i;//
				//while(isset($imid[$i]))
				//{
					if ($imid[$i])
					{
					
					//$src[$i]=read_image($imid[$i]->idImages);
					
					
						echo"<tr>";
			
							echo"<td  width=350 align='left'>"; echo "<a href=index.php?action=productpage&productId=$products->idProducts>".$products->title; echo "</td>";
							echo "<td width=380 align='left'>".$products->price;echo "</td>";
							echo"<td width=380 align='left'> <textarea cols = '10' rows = '7' wrap='hard' readonly='yes'>".$products->description; echo " </textarea> </td>";   
							echo"<td width=380 align='left'>".$products->quantity;echo "</td>";
						
						while($imid[$i]){$src[$i]=read_image($imid[$i]->idImages);	echo "<td> <img width=70px height=70px src='".$src[$i]."'/>";echo "</td>";// 
						$i++;echo"<td></td>";}//
						
						echo"<tr>";
					
					$i++;
					}
				
					else
					{
						echo"<tr>";
			
							echo"<td  width=350 align='left'>"; echo "<a href=index.php?action=productpage&productId=$products->idProducts>".$products->title; echo "</td>";
							echo "<td width=380 align='left'>".$products->price;echo "</td>";
							echo"<td width=380 align='left'> <textarea cols = '20' rows = '5' wrap='hard' readonly='yes'>".$products->description; echo " </textarea> </td>";   
							echo"<td width=380 align='left'>".$products->quantity;echo "</td>";
							echo "<td></td>";
							echo"<tr>";
					}
					//$i++;
					
				//}
				
				}
				
			}
			
	echo "</table>";
	
	}
	
}
else
	echo "Πρέπει να συνδεθείτε για να δείτε τα προϊόντα σας";
?>
